<?php
/**
 *
 * @author
 * @version
 */
class  Saleorders {
    /*
    *订单类型
    */
    public static function getordertype()
    {
        $sql = "SELECT  `number` ,  `value` FROM  `statusdics`
              WHERE  `table` =  'saleorders' AND  `colum_name` =  'orders_type'";
        $ordertypes = DB::query(Database::SELECT,$sql)->execute('newerp')->as_array();
        $types = array();
        foreach($ordertypes as $type){
            $types[$type['number']] = $type['value'];

        }
        return $types;

    }

    /**
     *
     * 通过国家英文名获取国家中文名
     */
    public static function getcountrycnname($country_enname){
//       $sql = "SELECT `country_en`,`country_cn` FROM `erp_country` WHERE
//                `country_en`='".mysql_escape_string($country_enname)."'";
//       $couns = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->current();
//       return isset($couns['country_cn'])?$couns['country_cn']:'无';
        $sql = "SELECT `country_en`,`country_cn` FROM `erp_country` WHERE
               `country_en` IN (".$country_enname.")";
        $couns = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->as_array();
        $country = array();
        foreach($couns as $coun){
            $country[trim($coun['country_en'])] = trim($coun['country_cn']);
        }
        return $country;
    }

    public static function getsalename($saleaccount){
//        $sql = "SELECT `service` FROM `erp_sales` WHERE `ebayaccount`='".mysql_escape_string($saleaccount)."'";
//        $salename = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->current();
//        return isset($salename['service'])?$salename['service']:'无';

        $sql = "SELECT `service`,ebayaccount  FROM `erp_sales` WHERE `ebayaccount` IN (".($saleaccount).")";
        $salename = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->as_array();
        $salesname = array();
        foreach($salename as $_name){
            $salesname[trim($_name['ebayaccount'])] =  trim($_name['service']);
        }
        return $salesname;
    }

    public static function getshipname($erp_post_office){
//        $sql = "SELECT `ship_name` FROM `erp_ship` WHERE `typeid`=".intval($erp_post_office);
//        $erp_postname = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->current();
//        return isset($erp_postname['ship_name'])?$erp_postname['ship_name']:'无';

          $sql = "SELECT `ship_name`,typeid FROM `erp_ship` WHERE `typeid` IN (".($erp_post_office).")";
          $erp_postname = DB::query(Database::SELECT,$sql)->execute('readonlyerp')->as_array();
         $ship_names  = array();
         foreach($erp_postname as $_name){
             $ship_names[trim($_name['typeid'])] = trim($_name['ship_name']);
         }
        return $ship_names;
    }

    public static function getorderstatus(){
        $sql = "SELECT  `number` ,  `value`  FROM  `statusdics`
              WHERE  `table` ='saleorders' AND  `colum_name` ='orders_status'";
        $orders_status = DB::query(Database::SELECT,$sql)->execute('newerp')->as_array();
        $ordersstatus = array();
        foreach($orders_status as $status){
            $ordersstatus[$status['number']] = $status['value'];
        }
        return $ordersstatus;
    }

}